import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;


public class SidePanel extends JPanel{

	/**
	 * Default Serialization
	 */
	private static final long serialVersionUID = 1L;
	
	private JLabel labels[];
	private int labelCounter;
	private JPanel labelPanel;
	
	public SidePanel(){
		super(new BorderLayout());
		labelPanel = new JPanel(new GridBagLayout());
		labelCounter = 0;
		labels = new JLabel[20];
		for (int i = 0; i < labels.length; i++){
			labels[i] = new JLabel();
			labels[i].setVisible(true);
			labels[i].setEnabled(false);
			
			final int specific = i;
			labels[i].addMouseListener(new MouseListener(){
				@Override
				public void mouseClicked(MouseEvent arg0){
					String value = labels[specific].getText();
					if (value.equals("c:\\Users\\Jamison\\workspace\\JLex.jar")){
						PrototypeGui.disp.addPicture(new File("c:\\Users\\Jamison\\Documents\\SE416\\JLex.png"));
					}
					else if (value.equals("c:\\Users\\Jamison\\workspace\\ClientEmail\\src")){
						PrototypeGui.disp.addPicture(new File("c:\\Users\\Jamison\\Documents\\SE416\\ClientEmail.png"));
					}
					for (int i = 0; i < labels.length; i++){
						if (i != specific){
							labels[i].setEnabled(false);
						}
					}
					labels[specific].setEnabled(true);
				}
				@Override
				public void mouseEntered(MouseEvent arg0){}
				@Override
				public void mouseExited(MouseEvent arg0){}
				@Override
				public void mousePressed(MouseEvent arg0){}
				@Override
				public void mouseReleased(MouseEvent arg0){}
			});
			
			GridBagConstraints gbc = new GridBagConstraints();
			gbc.gridx = 0;
			gbc.gridy = i;
			gbc.anchor = GridBagConstraints.NORTHWEST;
			gbc.weighty = 1;
			gbc.fill = GridBagConstraints.BOTH;
			labelPanel.add(labels[i], gbc);
		}
		add(labelPanel, BorderLayout.CENTER);
	}
	
	public void addProject(String name){
		labels[labelCounter].setText(name);
		for (int i = 0; i < labels.length; i++){
			if (i != labelCounter){
				labels[i].setEnabled(false);
			}
		}
		labels[labelCounter].setEnabled(true);
		labelCounter++;
	}
}
